var t, e = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), a = require("../../../@babel/runtime/helpers/asyncToGenerator"), r = getApp();

Page({
    data: {
        current_active: 0,
        active: 0,
        list: [],
        already_settlement_statistic: 0,
        not_settlement_statistic: 0,
        current_page: 1,
        last_page: 1
    },
    onChange: function(t) {
        var r = this;
        return a(e.default.mark(function a() {
            return e.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    return r.setData({
                        current_active: t.detail.index
                    }), e.next = 3, r.getData();

                  case 3:
                    return e.next = 5, r._get_detail();

                  case 5:
                  case "end":
                    return e.stop();
                }
            }, a);
        }))();
    },
    getData: function() {
        var t = this, e = this.get_current_type({
            type: "home"
        });
        r._getNetWork({
            url: r.getNetAddresss(e),
            success: function(e) {
                var a = e.data, n = a.result, i = a.msg, s = a.data, c = s.already_settlement_statistic, u = s.not_settlement_statistic;
                if (0 == n) return r.tips(i);
                t.setData({
                    already_settlement_statistic: c,
                    not_settlement_statistic: u
                });
            }
        });
    },
    get_current_type: function(t) {
        return "page" == t.type ? "plugin.sign-buy.frontend.reward-detail.record-page" : 0 == this.data.current_active ? "plugin.sign-buy.frontend.reward-detail.sign-profit" : 1 == this.data.current_active ? "plugin.sign-buy.frontend.reward-detail.recommend-award" : "plugin.sign-buy.frontend.reward-detail.allowance";
    },
    change: function(t) {
        this.setData({
            active: t.detail.index
        }), this._get_detail();
    },
    _get_detail: function() {
        var t = this, e = {
            reward_type: 0 == this.data.current_active ? "sign_profit" : 1 == this.data.current_active ? "recommend_award" : "allowance"
        }, a = this.get_current_type({
            type: "page"
        });
        0 !== this.data.active && (e.status = 1 == this.data.active ? 0 : 1), r._getNetWork({
            url: r.getNetAddresss(a),
            data: e,
            success: function(e) {
                var a = e.data, n = a.result, i = a.msg, s = a.data;
                if (0 == n) return r.tips(i);
                t.setData({
                    list: s.data,
                    current_page: s.current_page,
                    last_page: s.last_page
                });
            }
        });
    },
    onLoad: (t = a(e.default.mark(function t(a) {
        return e.default.wrap(function(t) {
            for (;;) switch (t.prev = t.next) {
              case 0:
                return t.next = 2, this.getData();

              case 2:
                return t.next = 4, this._get_detail();

              case 4:
              case "end":
                return t.stop();
            }
        }, t, this);
    })), function(e) {
        return t.apply(this, arguments);
    }),
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        var t = this;
        if (!(this.data.current_page >= this.data.last_page)) {
            var e = {
                reward_type: 0 == this.data.current_active ? "sign_profit" : 1 == this.data.current_active ? "recommend_award" : "allowance"
            }, a = this.get_current_type({
                type: "page"
            });
            e.page = this.data.current_page + 1, 0 !== this.data.active && (e.status = this.data.active), 
            r._getNetWork({
                url: r.getNetAddresss(a),
                data: e,
                success: function(e) {
                    var a = e.data, n = a.result, i = a.msg, s = a.data, c = s.already_settlement_statistic, u = s.not_settlement_statistic, d = s.record;
                    if (0 == n) return r.tips(i);
                    var o = t.data.list.concat(d.data);
                    t.setData({
                        list: o,
                        current_page: d.current_page,
                        last_page: d.last_page,
                        already_settlement_statistic: c,
                        not_settlement_statistic: u
                    });
                }
            });
        }
    },
    onShareAppMessage: function() {}
});